package de.dlrg.wms.model;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import com.google.code.trapo.validation.Unique;

import wms2010.interfaces.devices.IDevice;

@javax.persistence.Entity
public class Track {
	public static Track TrackNull = new de.dlrg.wms.model.NullClasses.TrackNull();
	/**
	 * 
	 */
	private static final long serialVersionUID = -288612039936116503L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@javax.persistence.Transient
	private IDevice stopperDevice;
	@Column(unique=true)
	@Unique(entity = Track.class, field = "trackNumber")
	private Integer trackNumber;

	public Long getId() {
		return id;
	}

	public IDevice getStopperDevice() {
		return stopperDevice;
	}

	public Integer getTrackNumber() {
		return trackNumber;
	}

	public Track setId(Long id) {
		this.id = id;
		return this;
	}

	public Track setStopperDevice(IDevice stopperDevice) {
		this.stopperDevice = stopperDevice;
		return this;
	}

	public Track setTrackNumber(Integer trackNumber) {
		this.trackNumber = trackNumber;
		return this;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Track) {
			Track track = (Track) obj;
			boolean ret = (track.getId().equals(this.getId()));
			return ret;
		}
		return super.equals(obj);
	}
}
